using System;
using VisualWip.Core;
using VisualWip.Core.Columns;

namespace VisualWip.PresentationModel.WorkItem
{
    public class WorkColumnViewModelBase : ColumnViewModelBase
    {
        protected WorkColumnBase WorkColumnBase;

        public WorkColumnViewModelBase(Application application, WorkColumnBase workColumnBase,
                                       IColumnBuilder columnBuilder)
            : base(application, workColumnBase, columnBuilder)
        {
            WorkColumnBase = workColumnBase;
        }

        public int WorkInProgress
        {
            get { return WorkColumnBase.WorkInProgress; }
        }

        public int WorkInProgressLimit
        {
            get { return WorkColumnBase.WorkInProgressLimit; }
        }

        public bool HasWorkInProgressLimit
        {
            get { return WorkColumnBase.HasWorkInProgressLimit; }
        }

        public bool IsOverWorkInProgressLimit
        {
            get { return WorkColumnBase.IsOverWorkInProgressLimit; }
        }

        public bool IsAtWorkInProgressLimit
        {
            get { return WorkColumnBase.IsAtWorkInProgressLimit; }
        }

        public bool IsInWorkInProgressLimit
        {
            get { return WorkColumnBase.IsInWorkInProgressLimit; }
        }

        public bool ShowWorkInProgressLimit
        {
            get { return WorkColumnBase.ShowWorkInProgressLimit; }
        }

        protected override void ColumnRefreshDone(object sender, EventArgs e)
        {
            base.ColumnRefreshDone(sender, e);
            OnPropertyChanged(this, () => WorkInProgress);
            OnPropertyChanged(this, () => WorkInProgressLimit);
            OnPropertyChanged(this, () => IsOverWorkInProgressLimit);
            OnPropertyChanged(this, () => IsAtWorkInProgressLimit);
            OnPropertyChanged(this, () => IsInWorkInProgressLimit);
            OnPropertyChanged(this, () => HasWorkInProgressLimit);
            OnPropertyChanged(this, () => ShowWorkInProgressLimit);
        }

        protected override void ColumnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.ColumnPropertyChanged(sender, e);
            BubbleOnPropertyChanged(e, () => WorkInProgress);
            BubbleOnPropertyChanged(e, () => WorkInProgressLimit);
            BubbleOnPropertyChanged(e, () => IsOverWorkInProgressLimit);
            BubbleOnPropertyChanged(e, () => IsAtWorkInProgressLimit);
            BubbleOnPropertyChanged(e, () => IsInWorkInProgressLimit);
            BubbleOnPropertyChanged(e, () => HasWorkInProgressLimit);
            BubbleOnPropertyChanged(e, () => ShowWorkInProgressLimit);
        }
    }
}